package com.yuyuan.notice.utils;

import com.yuyuan.notice.mapper.NoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author: kestrel
 * @Version:1.0
 * @Date: 2024/6/13
 */
@Component
public class MyUtils {
    /**
     * 处理分页查询中起始id为0的问题
     * @param startId 起始id
     * @return 处理后的startId变量
     */

    @Autowired
    private NoticeMapper noticeMapper;

    public long zeroHandler(Long startId, Long blogType, String type) {
        if (startId != 0) return startId;
        switch (type) {
            case "NoticeDTOC":
                // 这里blogType是userId
                startId = noticeMapper.getMaxStartId(blogType) + 1;
                break;
        }
        System.out.println(startId);
        return startId;
    }
}
